package com.hnhs.service;

import com.hnhs.mapper.CategoryDao;
import com.hnhs.mapper.ProductDao;
import com.hnhs.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductService {

    @Autowired
    private ProductDao productDao;

    public List<Product> select(ProductQuery query){
        List<Product> select = productDao.select(query);
        return select;
    }

    public int insert(Product product){
        return productDao.insert(product);
    }

    public int update(Product product){
       return productDao.update(product);
    }

    //软删除 逻辑删除 只改状态不删除数据
   public int delete(Integer id){
        return productDao.updateStatus(id,0);
   }


    public Integer updateStatus(ProductStatusUpdater updater) {
        return productDao.updateStatus(updater.getId(),updater.getStatus());
    }
}
